chore: improve incompatible types error#2279
Conversation
WalkthroughReplaced positional Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (2)controlplane/test/composition-errors.test.ts (4)
composition/src/errors/errors.ts (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
🔇 Additional comments (2)
Comment |
Router-nonroot image scan passed✅ No security vulnerabilities found in image: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
composition/src/errors/errors.ts (1)
344-358: Approve the refactor; consider simplifying array creation.The refactor from positional parameters to an object-parameter API improves maintainability and clarity. The error message construction correctly handles both explicit
incomingNodeTypeand the Interface Object fallback case.On line 349, consider using a more concise array creation:
- const existingSubgraphNames = new Array<SubgraphName>(...existingData.subgraphNames); + const existingSubgraphNames = Array.from(existingData.subgraphNames);or
- const existingSubgraphNames = new Array<SubgraphName>(...existingData.subgraphNames); + const existingSubgraphNames = [...existingData.subgraphNames];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
composition/src/errors/errors.ts(4 hunks)composition/src/errors/types.ts(2 hunks)composition/src/v1/federation/federation-factory.ts(4 hunks)composition/tests/v1/entity-interface.test.ts(4 hunks)composition/tests/v1/federation-factory.test.ts(3 hunks)controlplane/test/composition-errors.test.ts(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
composition/src/errors/types.ts (2)
composition/src/schema-building/types.ts (1)
ParentDefinitionData(242-248)composition/src/types/types.ts (1)
SubgraphName(9-9)
composition/tests/v1/entity-interface.test.ts (8)
composition/tests/utils/utils.ts (1)
federateSubgraphsFailure(49-57)composition/src/router-compatibility-version/router-compatibility-version.ts (1)
ROUTER_COMPATIBILITY_VERSION_ONE(3-3)composition/src/utils/string-constants.ts (2)
INTERFACE(75-75)OBJECT(104-104)composition/src/types/types.ts (1)
SubgraphName(9-9)composition/src/schema-building/types.ts (2)
InterfaceDefinitionData(157-172)ObjectDefinitionData(174-191)composition/src/errors/errors.ts (1)
incompatibleParentTypeMergeError(344-358)composition/src/subgraph/types.ts (1)
Subgraph(11-15)composition/src/ast/utils.ts (1)
parse(272-274)
composition/tests/v1/federation-factory.test.ts (5)
composition/src/utils/string-constants.ts (3)
OBJECT(104-104)SCALAR(124-124)INPUT_OBJECT(71-71)composition/src/schema-building/types.ts (3)
ScalarDefinitionData(209-219)ObjectDefinitionData(174-191)InputObjectDefinitionData(120-132)composition/src/errors/errors.ts (2)
incompatibleParentTypeMergeError(344-358)noBaseDefinitionForExtensionError(158-163)composition/tests/utils/utils.ts (1)
federateSubgraphsFailure(49-57)composition/src/router-compatibility-version/router-compatibility-version.ts (1)
ROUTER_COMPATIBILITY_VERSION_ONE(3-3)
controlplane/test/composition-errors.test.ts (2)
composition/src/errors/errors.ts (2)
incompatibleMergedTypesError(70-80)incompatibleParentTypeMergeError(344-358)composition/src/utils/string-constants.ts (4)
STRING_SCALAR(140-140)INT_SCALAR(74-74)OBJECT(104-104)INTERFACE(75-75)
composition/src/errors/errors.ts (4)
composition/src/errors/types.ts (1)
IncompatibleParentKindMergeErrorParams(38-42)composition/src/resolvability-graph/types/types.ts (1)
SubgraphName(13-13)composition/src/utils/utils.ts (1)
kindToNodeType(72-141)composition/src/resolvability-graph/constants/string-constants.ts (1)
QUOTATION_JOIN(8-8)
composition/src/v1/federation/federation-factory.ts (4)
composition/src/schema-building/types.ts (1)
ParentDefinitionData(242-248)composition/src/resolvability-graph/types/types.ts (1)
SubgraphName(13-13)composition/src/errors/errors.ts (1)
incompatibleParentTypeMergeError(344-358)composition/src/utils/utils.ts (1)
kindToNodeType(72-141)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: build_push_image (nonroot)
- GitHub Check: image_scan (nonroot)
- GitHub Check: build_push_image
- GitHub Check: image_scan
- GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
- GitHub Check: integration_test (./telemetry)
- GitHub Check: integration_test (./events)
- GitHub Check: build_test
- GitHub Check: build_test
- GitHub Check: build_push_image
- GitHub Check: build_test
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: build_push_image
- GitHub Check: build_test
🔇 Additional comments (4)
composition/src/errors/errors.ts (4)
10-10: LGTM! Import supports the refactored error function.The
IncompatibleParentKindMergeErrorParamstype import is correctly added to support the new object-parameter signature ofincompatibleParentTypeMergeError.
43-43: LGTM! Type imports support the refactored function.The imports of
NodeType,SubgraphName, andTypeNameare correctly added to support the new function signature and typing.
342-342: LGTM! Clear constant for Interface Object description.The
interfaceObjectconstant provides a well-formatted description for use in error messages when the incoming node type is not explicitly provided.
383-383: LGTM! Formatting consistency improvement.Adding quotes around
expectedTypeStringimproves consistency with other error messages in the file and makes the error output clearer.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
composition/src/errors/errors.ts (1)
349-356: Prefer array literal copy for readability.
new Array(...existingData.subgraphNames)works, but it reads like the length-based constructor and will misbehave if anything ever supplies a numeric value.[...existingData.subgraphNames]orArray.from(existingData.subgraphNames)communicates the intent to clone an iterable without that footgun. Consider switching to one of those forms.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
composition/src/errors/errors.ts(4 hunks)composition/src/errors/types.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- composition/src/errors/types.ts
🧰 Additional context used
🧬 Code graph analysis (1)
composition/src/errors/errors.ts (4)
composition/src/errors/types.ts (1)
IncompatibleParentTypeMergeErrorParams(38-42)composition/src/types/types.ts (1)
SubgraphName(9-9)composition/src/utils/utils.ts (1)
kindToNodeType(72-141)composition/src/resolvability-graph/constants/string-constants.ts (1)
QUOTATION_JOIN(8-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
- GitHub Check: integration_test (./telemetry)
- GitHub Check: build_push_image (nonroot)
- GitHub Check: build_push_image
- GitHub Check: integration_test (./events)
- GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
- GitHub Check: build_test
- GitHub Check: Analyze (go)
- GitHub Check: build_test
- GitHub Check: build_push_image
- GitHub Check: build_test
- GitHub Check: build_push_image
- GitHub Check: build_test
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Checklist